A 1140px wide, 12 column grid. Fluid all the way down to a mobile version.

The 1140 grid fits perfectly into a 1280 monitor. On smaller monitors it becomes fluid and adapts to the width of the browser.

Beyond a certain point it uses media queries to serve up a mobile version, which essentially stacks all the columns on top of each other so the flow of information still makes sense.

Scrap 1024! Design once at 1140 for 1280, and with very little extra work, it will adapt itself to work on just about any monitor, even mobile.

If you use it, I'd love to see the results. @andytlr on Twitter or hello@andytlr.com

 

Why 12 columns?

Twelve divides into even columns of two, three, four or six.

Or into numerous uneven combinations like seven and five or five, four, three.

The last example is as simple as three divs with the classes .fivecol, .fourcol and .threecol

Photoshop Template

Download a Photoshop template of the grid at 1140px here. It's based on how it's displayed in WebKit, so it's actually 1133px, as all browsers round sub-pixels slightly differently.

Mobile version

By mobile, I really mean smart phones. I'm not even attempting to support WAP phones or anything old like that. But it does work on devices that recognise 'handheld' in the style sheet media and/or media queries. With media queries you can even include x2 images for the iPhone 4 Retina Display.

New computers, old computers, netbooks, tablets, smartphones, some feature phones.

So far I've tested it on a couple of MacBooks, an iMac, a PC laptop, an old PC, an Eee PC, an iPad, an iPhone 3G, an iPhone 4, a few Android phones, a Samsung Galaxy Tab, a BlackBerry and an older Nokia.

Browser support

It works perfectly in Chrome, Safari, Firefox, IE7 & IE8.

It works alright in IE6. IE6 doesn't support max-width, so the grid doesn't fix to 1140px. It spans the full width of the browser. Most people using IE6 probably don't have monitors with a resolution higher than 1280x1024 though. Images are also not restrained to the width of the column because of max-width. But the extra image is hidden, rather than breaking the layout.

Note: IE6 accounts for less than 1% of total traffic to my blog. Check your analytics.

Bigger gutters

Because it's all based off percentages, the gutters vary in size. But at full width the gutters are about 40px wide.

Images

If an image is smaller than the column it is contained in, it will be displayed at its original size. If it is larger then it will be shrunk to the width of the column. Don't define height and width of images inline, it'll break the proportions if they're scaled down.

Lily

The markup

<div class="container">

<div class="row">
<div class="threecol">
<p>Column 1</p>
</div>
<div class="threecol">
<p>Column 2</p>
</div>

<div class="threecol">
<p>Column 3</p>
</div>
<div class="threecol last">
<p>Column 4</p>
</div>

</div>
</div>
		

Explanation of the classes and markup

.container
Is a full width div that allows layouts to have a background that spans the full width of the browser. It also contains 20px padding on either side to keep content away from the edges when it becomes fluid. You can just use one big container, or use multiple to break the page horizontally.

.row
Is a row of columns. It centres them and defines the 1140px max-width.

.onecol, .twocol, .threecol, .fourcol, .fivecol, .sixcol, .sevencol, .eightcol, .ninecol, .tencol, .elevencol, .twelvecol
Are the classes for each column. They can be used in any combination within a row that adds up to twelve or less.

.last
The last column within a row also needs this class. It removes the right margin so all the columns fit within the row.

Updates

1.6: Better fix for the Firefox bug. Stopped columns floating in the mobile version. Thanks @davemcdermid

1.5: Fixed a bug where Firefox wasn't recognising max-width for images in the mobile layout.

1.4: Changed the viewport meta tag to include 'initial scale 1'. This means devices will use the width of the device in landscape mode. Previously the iPad would use 768px in both portrait and landscape.

1.3: Fixed the width of .eightcol

Creative Commons License